package com.ktjy.config;

import com.ktjy.entity.SysRole;
import com.ktjy.entity.SysUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

@Configuration
@PropertySource(value = "classpath:user.properties",encoding = "UTF-8")
@ComponentScan(basePackages = "com.ktjy.mapper")
@ImportResource("classpath:Daoconfig.class")

public class Userconfig {
    @Value("${user.realName}")
    private String realName;
    @Value("${user.account}")
    private String account;
    @Value("${user.password}")
    private String password;
    @Value("${user.sex}")
    private int sex;
    @Bean
    public SysUser sysUser(SysRole role) {
        SysUser sysUser = new SysUser();
        sysUser.setRealName(realName);
        sysUser.setAccount(account);
        sysUser.setPassword(password);
        sysUser.setSex(sex);
        sysUser.setRole(role);
        return sysUser;
    }
    @Bean
    public SysRole adminRole(){
        SysRole role=new SysRole();
        role.setId(1l);
        role.setRoleName("管理员");
        role.setCode("ADMIN");
        return role;
    }
}
